#include "network.h"
#include "string.h"
#include "stdio.h"
#include "FreeRTOS.h"
#include "task.h"
#include "modbus.h"
#include "main.h"
#include "buzzer.h"

void NetWorkInsertReplyReq(uint8_t * data, uint8_t leng)
{
	if(networkBufStruct.leng > _NETWORK_MAX_PACK_SIZE)
	{
		networkBufStruct.leng = 0;
	}
}

void NetWorkTask(void *pvParametes)
{
	//struct pbuf * pb;
	//struct ip_addr addr;
	//struct udp_pcb *pcb;
	//addr.addr = 0xFFFFFFFF;
	ETH_BSP_Config();
	LwIP_Init();
	vTaskDelay(1000);
	if(netStruct.DHCP_use == 1)
	{
		while((DHCP_state < DHCP_ADDRESS_ASSIGNED))
			/* while get dhcp */
			vTaskDelay(100);
		if(DHCP_state == DHCP_TIMEOUT)
		{
			BuzzerON_Error();
			while(1);
		}
		if(DHCP_state == DHCP_ADDRESS_ASSIGNED)
			BuzzerON_Once();
	}
	for(;;)
	{

		/* pause */
		vTaskDelay(1500);
	}
}
